//
//  CertificationStatesViewModel.swift
//  Exchange
//
//  Created by 孟祥群 on 2018/6/22.
//  Copyright © 2018年 common. All rights reserved.
//

import UIKit

class CertificationStatesViewModel: BaseViewModel {
    @objc dynamic  var refreshBool = false //监听的状态
    var isChinese = true
    var model:CertificationStatesModel = CertificationStatesModel()
    lazy var identyRequest:IdentyInforRequest = {
        let api = IdentyInforRequest()
        api.dataReformer = self
        api.paramSource = self
        api.delegate = self
        return api
    }()
    
    func archiveInformation() {
        self.request(request: identyRequest, success: {[weak self] (result) in
            if result?["data"] as? [String : Any] == nil  {
                return
            }
            self?.model = CertificationStatesModel(JSON: result?["data"] as! [String : Any])!
            if AppSecurityInfo.default.model.seniorAuth != self?.model.seniorAuth {
                AppSecurityInfo.default.model.seniorAuth = (self?.model.seniorAuth)!
                NotificationCenter.default.post(name: NSNotification.Name.Exchange.securityDidChange, object: nil)
            }
            if self?.model.country == kText("中国") || self?.model.country == "中国" || self?.model.country.count == 0 {
                self?.isChinese = true
            }else {
                self?.isChinese = false
            }
            self?.refreshBool = true
            
        }) { (response) in
            
        }
    }
}
extension CertificationStatesViewModel:RequestCallBack,RequestDataReformer,RequestParamSource {
    func reform(_ request: BaseRequest, _ data: [String : Any]?) {
        if successBlock != nil {
            successBlock!(data)
        }
    }
    
    func requestDidSucess(_ request: BaseRequest) {
        
    }
    
    func requestDidFail(_ request: BaseRequest) {
        if failBlock != nil {
            failBlock!(request)
        }
    }
    
    func requestParams(_ request: BaseRequest) -> [String : Any]? {
        let pramas: [String:Any] = [:]
        if let _ = request as? IdentyRequest {
       
        }
        
        return pramas
    }
}
